//
//  NSMutableArray+Extension.m
//  ICome
//
//  Created by zhang_rongwu on 16/3/3.
//  Copyright © 2016年 XianZhuangGuo. All rights reserved.
//

#import "NSMutableArray+Extension.h"
#import "NSObject+Extension.h"
@implementation NSMutableArray (Extension)
+ (void)load {
    [self swizzleInstanceMethod:NSClassFromString(@"__NSArrayM") originSelector:@selector(addObject:) otherSelector:@selector(WRAddObject:)];
   
    [self swizzleInstanceMethod:NSClassFromString(@"__NSArrayM") originSelector:@selector(objectAtIndex:) otherSelector:@selector(WRObjectAtIndex:)];
    
    [self swizzleInstanceMethod:NSClassFromString(@"__NSArrayM") originSelector:@selector(removeObjectAtIndex:) otherSelector:@selector(WRRemoveObjectAtIndex:)];
}

- (void)WRAddObject:(id)object
{
    @autoreleasepool {
        if (object != nil) {
            [self WRAddObject:object];
        }
    }
}

- (id)WRObjectAtIndex:(NSUInteger)index
{
    @autoreleasepool {
        if (index < self.count) {
            return [self WRObjectAtIndex:index];
        } else {
            return nil;
        }
    }
}

- (void)WRRemoveObjectAtIndex:(NSUInteger)index {
    @autoreleasepool {
        if (index < self.count) {
            [self WRRemoveObjectAtIndex:index];
        }
    }
}

@end
